#include <iostream>
using namespace std;

class BaseClass
{
public:
    virtual ~BaseClass()
    {
        cout << "BaseClass执行析构函数" << endl;
    }
};

class DerivedClass : public BaseClass
{
public:
    ~DerivedClass()
    {
        cout << "DerivedClass执行析构函数" << endl;
    }
};

int main()
{
    DerivedClass *p = new DerivedClass;
    BaseClass *q = p;
    delete q;
    
    return 0;
}